<!--
 * @Author: yushuang
 * @Date: 2024-12-03 15:58:14
 * @LastEditors: yushuang
 * @LastEditTime: 2025-02-10 17:08:36
 * @Description: 
-->
<script setup lang="ts">
import { storeToRefs } from 'pinia';
import { useAppStore } from '@/stores/app';
import TokenProvider from '@/components/token-provider/index.vue';
import { useCompConsumer } from '@/composables/comp-consumer';
import { useAuthorization } from '@/composables/authorization';

const appStore = useAppStore();
const { theme } = storeToRefs(appStore);

const { layoutSetting } = storeToRefs(appStore);
const cacheList = [];
const { getComp } = useCompConsumer();
const token = useAuthorization();
token.value = localStorage.getItem('token');
</script>

<template>
  <a-config-provider :theme="theme">
    <a-app class="h-full font-chinese antialiased">
      <TokenProvider>
        <RouterView>
          <template #default="{ Component, route }">
            <Transition appear :name="layoutSetting.animationName" mode="out-in">
              <KeepAlive v-if="layoutSetting.keepAlive" :include="[...cacheList]">
                <component :is="getComp(Component)" :key="route.fullPath" />
              </KeepAlive>
              <component :is="Component" v-else :key="route.fullPath" />
            </Transition>
          </template>
        </RouterView>
      </TokenProvider>
    </a-app>
  </a-config-provider>
</template>
